namespace ExtractFunctoid.Maps {
    
    
    [Microsoft.XLANGs.BaseTypes.SchemaReference(@"ExtractFunctoid.Schemas.CustomerList", typeof(global::ExtractFunctoid.Schemas.CustomerList))]
    [Microsoft.XLANGs.BaseTypes.SchemaReference(@"ExtractFunctoid.Schemas.Customers", typeof(global::ExtractFunctoid.Schemas.Customers))]
    public sealed class CustomerList_To_Customers : global::Microsoft.XLANGs.BaseTypes.TransformBase {
        
        private const string _strMap = @"<?xml version=""1.0"" encoding=""UTF-16""?>
<xsl:stylesheet xmlns:xsl=""http://www.w3.org/1999/XSL/Transform"" xmlns:msxsl=""urn:schemas-microsoft-com:xslt"" xmlns:var=""http://schemas.microsoft.com/BizTalk/2003/var"" exclude-result-prefixes=""msxsl var s0 userCSharp"" version=""1.0"" xmlns:s0=""http://ExtractFunctoid.Schemas.CustomerList"" xmlns:ns0=""http://ExtractFunctoid.Schemas.Customers"" xmlns:userCSharp=""http://schemas.microsoft.com/BizTalk/2003/userCSharp"">
  <xsl:output omit-xml-declaration=""yes"" method=""xml"" version=""1.0"" />
  <xsl:template match=""/"">
    <xsl:apply-templates select=""/s0:CustomerList"" />
  </xsl:template>
  <xsl:template match=""/s0:CustomerList"">
    <xsl:variable name=""var:v1"" select=""userCSharp:StringSubstring(string(Customers/text()) , &quot;0&quot; , &quot;|&quot;)"" />
    <ns0:Customers>
      <Customer>
        <xsl:value-of select=""$var:v1"" />
      </Customer>
    </ns0:Customers>
  </xsl:template>
  <msxsl:script language=""C#"" implements-prefix=""userCSharp""><![CDATA[
public string StringSubstring(string str, string left, string right)
{
	string retval = """";
	double dleft = 0;
	double dright = 0;
	if (str != null && IsNumeric(left, ref dleft) && IsNumeric(right, ref dright))
	{
		int lt = (int)dleft;
		int rt = (int)dright;
		lt--; rt--;
		if (lt >= 0 && rt >= lt && lt < str.Length)
		{
			if (rt < str.Length)
			{
				retval = str.Substring(lt, rt-lt+1);
			}
			else
			{
				retval = str.Substring(lt, str.Length-lt);
			}
		}
	}
	return retval;
}


public bool IsNumeric(string val)
{
	if (val == null)
	{
		return false;
	}
	double d = 0;
	return Double.TryParse(val, System.Globalization.NumberStyles.AllowThousands | System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out d);
}

public bool IsNumeric(string val, ref double d)
{
	if (val == null)
	{
		return false;
	}
	return Double.TryParse(val, System.Globalization.NumberStyles.AllowThousands | System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out d);
}


]]></msxsl:script>
</xsl:stylesheet>";
        
        private const string _strArgList = @"<ExtensionObjects />";
        
        private const string _strSrcSchemasList0 = @"ExtractFunctoid.Schemas.CustomerList";
        
        private const global::ExtractFunctoid.Schemas.CustomerList _srcSchemaTypeReference0 = null;
        
        private const string _strTrgSchemasList0 = @"ExtractFunctoid.Schemas.Customers";
        
        private const global::ExtractFunctoid.Schemas.Customers _trgSchemaTypeReference0 = null;
        
        public override string XmlContent {
            get {
                return _strMap;
            }
        }
        
        public override string XsltArgumentListContent {
            get {
                return _strArgList;
            }
        }
        
        public override string[] SourceSchemas {
            get {
                string[] _SrcSchemas = new string [1];
                _SrcSchemas[0] = @"ExtractFunctoid.Schemas.CustomerList";
                return _SrcSchemas;
            }
        }
        
        public override string[] TargetSchemas {
            get {
                string[] _TrgSchemas = new string [1];
                _TrgSchemas[0] = @"ExtractFunctoid.Schemas.Customers";
                return _TrgSchemas;
            }
        }
    }
}
